//
//  ShareTableView.m
//  wtshoppingcite
//
//  Created by TW on 15-3-26.
//  Copyright (c) 2015年 TW. All rights reserved.
//

#import "ShareTableView.h"
#import "ShareCell.h"

@implementation ShareTableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    
    self = [super initWithFrame:frame style:style];
    if(self){
        self.backgroundView = nil;
        self.backgroundColor = [UIColor whiteColor];
        self.dataSource = self;
        self.delegate = self;
        self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
    }
    return self;
}


#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ShareModel *shareModel = self.data[indexPath.row];
    if ([shareModel.smallImgPath isEqualToString:@""] || [shareModel.smallImgPath isEqualToString:@"(null)"]) {
        return 120;
    }else{
        return 220;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    ShareCell *cell = [tableView dequeueReusableCellWithIdentifier:@"shareCell"];
    if (cell == nil) {
        cell = [[ShareCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shareCell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.shareModel = self.data[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(self.eventsDelegate!= nil  && [self.eventsDelegate respondsToSelector:@selector(basetableView:didSelectRowAtIndexPath:)]){
        [self.eventsDelegate basetableView:self didSelectRowAtIndexPath:indexPath];
    }
    
}
@end
